<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="t" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<s:url var="remove_anotacao_ajax_url" value="/anotacoes/remove"/>

<c:forEach var="anotacao" items="${anotacoes}">
    <div class="itemdiv dialogdiv">
        <div class="user">
            <img alt="Foto do Usuário" src="<c:url value='/assets/avatars/avatar2.png'/>" />
        </div>

        <div class="body">

            <div class="time"><i class="icon-time"></i> <span class="blue">${anotacao.dataCriacaoFormatted}</span></div>
            <div class="name">
                <a href="#">
                    ${anotacao.user}
                </a>


            </div>
            <div class="text">
                <i class="icon-quote-left"></i>
                ${anotacao.texto}
                <c:if test="${anotacao.visibleInWebpage ==  true}">
                    <span data-rel="tooltip" data-placement="bottom" title="Visível na Página Web"><i class="icon-eye-open"></i></span>
                    </c:if>
                    <c:if test="${anotacao.visibleInWebpage == false}">
                    <span data-rel="tooltip" data-placement="bottom" title="Não Visível na Página Web"><i class="icon-eye-close"></i></span>                </c:if>

                </div>

            <c:if test="${turma.organizacaoGestora.equals(userOrganization)}">
                <div class="tools">

                    <div class="inline position-relative">
                        <button class="btn btn-minier bigger btn-yellow dropdown-toggle" data-toggle="dropdown">
                            <i class="icon-angle-down icon-only bigger-120"></i>
                        </button>

                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">


                            <li>

                                <a href="javascript:removeAnotacao(${anotacao.id}, '${anotacao.objectId}', 'NORMAL')" class="tooltip-error" data-rel="tooltip" title="Delete">
                                    <span class="red">
                                        <i class="icon-trash bigger-110"></i>
                                    </span>
                                </a>

                            </li>
                        </ul>
                    </div>

                </div>
            </c:if>
        </div>
    </div>

</c:forEach>



<script type="text/javascript">
    function removeAnotacao(id) {

        var answer = confirm("Tem certeza de que deseja excluir definitivamente este comentário?");
        if (answer) {
            $.ajax({
                url: "${remove_anotacao_ajax_url}",
                data: {anotacaoId: id},
                cache: false
            }).done(function(json) {
                loadAnotacoes();
            });
        }
    }


</script>
